package com.example.authority.util;



import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import org.springframework.stereotype.Component;

import java.io.IOException;

import java.util.concurrent.TimeoutException;

@Component
public class ConnectionUtils {

    public static Connection getChannel() throws IOException, TimeoutException {
        ConnectionFactory connFactory=new ConnectionFactory();
        //设置服务器位置
        connFactory.setHost("localhost");
        //设置服务器端口号
        connFactory.setPort(5672);
        connFactory.setShutdownTimeout(10000);
        //创建连接
        return connFactory.newConnection();
    }
}
